package com.artPreter.controller;


import com.artPreter.pojo.IndexType;
import com.artPreter.pojo.Result;
import com.artPreter.service.IIndexsTypeService;
import com.artPreter.service.impl.IndexTypeServiceImpl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 艺术分类表 前端控制器
 * </p>
 *
 * @author jarvis
 * @since 2024-12-10
 */
@RestController
@RequestMapping("/indexType")
public class IndexTypeController {


    @Autowired
    private IndexTypeServiceImpl indexTypeService;

    /**
     * 首页板块分页
     * @param currentPage
     * @param size
     * @param
     * @return
     */
    @PostMapping("/getPage")
    public Result getPage(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody IndexType indexType) {
        IPage<IndexType> indexTypeIPage = indexTypeService.getPage(currentPage, size, indexType);
        return Result.success(indexTypeIPage);
    }

    /**
     *  添加首页板块
     * @param indexType
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody IndexType indexType) {
        indexTypeService.add(indexType);
        return Result.success();
    }

    /**
     *  修改首页板块
     * @param
     * @return
     */
    @PostMapping("/edit")
    public Result edit(@RequestBody IndexType indexType) {
        indexTypeService.edit(indexType);
        return Result.success();
    }

    /**
     * 删除首页板块
     * @param
     * @return
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody IndexType indexType){
        indexTypeService.delete(indexType);
        return Result.success();
    }

    /**
     * 获取首页板块列表
     * @param
     * @return
     */
    @PostMapping("/getList")
    public Result getList(@RequestBody IndexType indexType){
        List<IndexType> result = indexTypeService.getList(indexType);
        return Result.success(result);
    }

}
